<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="项目营业日报表" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doSearch(){
		var startDate=document.getElementById("start_date").value;
		var endDate=document.getElementById("end_date").value;
		var tsId=document.getElementById("ts_id").value;
		
		if(startDate!=null && startDate!=''){
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return;
			}
		}else{
			ShowAlert('提示框','请选择开始日期',200,100);
			return;
		}
		if(endDate!=null && endDate!=''){
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return;
			}
		}else{
			ShowAlert('提示框','请选择结束日期',200,100);
			return;
		}
		
		window.location="/business/MtBusinessDate.ihtm?start_date="+startDate+"&end_date="+endDate+"&ts_id="+tsId;
	}
	
	function getSearchCondition(){
		var startDate="${startDate}";
		var endDate="${endDate}";
		var tsId="${tsId}";
		var str="start_date="+startDate+"&end_date="+endDate+"&ts_id="+tsId;
		return str;
	}
	function doDownload(){
		var str=getSearchCondition();
		window.location="/business/MtBusinessDate.ihtm?content_type=EXCEL&"+str;
	}
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="TODAY"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="YESTERDAY"){
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
	}
	function DoubleClick(it){
		
	}
	function showDetail(mtId){
		var url="/business/BusinessBillItemSearchResult.ihtm?search_type=1&cb_make_type=1&make_type="+mtId+"&cb_order_date=1&start_date=${startDate}&end_date=${endDate}&cb_examine=1&examined=Y";
		var tsId="${tsId}";
		if(tsId!="" && tsId!="0"){
			url=url+"&cb_ts=1&ts_id="+tsId;
		}
		showWin(1024,600,url);
	}
</script>
</head>
<body class="sheet" style="text-align:center;">
<div class="sheet-main" style="width:860px;text-align:left;margin:auto;">
  <div class="sheet-top">
    <div class="content">
      <h2>项目营业日报表</h2>
      <p>统计指定期间的各个项目的交易笔数与营业额</p>
    </div>
  </div>
  <div class="sheet-list">
    	<div class="search-business">
	      <div class="content">
	        <table width="100%">
	          <tbody>
	            <tr>
	              <td align="right">
					日期：
					<input type="text" class="TextBox Datetime"  maxlength="15" onKeyUp="checkInput();" id="start_date" name="start_date" value="${startDate}">
					<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this);">
					至<input class="TextBox Datetime" type="text" maxlength="15" onKeyUp="checkInput();" id="end_date" name="end_date" value="${endDate}">
					<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this);">											
					<a href="javascript:setDate('CURRENT_MONTH');">本月</a>
					<a href="javascript:setDate('TODAY');">今天</a>
					<a href="javascript:setDate('YESTERDAY');">昨天</a>
					<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
					<select name="ts_id" id="ts_id">
						<option value="0">==请选择帐套==</option>
						<c:forEach var="item" items="${tsList}">
							<option value="${item.id}" <c:if test="${tsId==item.id}">selected</c:if>>${item.title}</option>
						</c:forEach>
		  			</select>
					<input type="button"  value=" 查 询" onClick="doSearch();"  class="buttom search-but">
					<input type="button" value=" 导 出" onClick="doDownload();" class="buttom search-out" id="sDownloadButton" name="sDownloadButton" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';NO_EXPO;')!=-1}">disabled="true"</c:if>>
				   </td>
	            </tr>    
	            </tbody>      
	        </table>      	 
	      </div>
		  
		  <div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>&nbsp;&nbsp;项目合计：${busTotal}元&nbsp;&nbsp;优惠合计：${favTotal}元&nbsp;&nbsp;实际营业额：${costTotal}元</td>
	            	</tr>
	            </table>
		  </div>
		  
	      <div class="table-list">
	      		<table width="100%">
					<tr>
						<th width="60%">项目类型</th>
						<th width="20%">数量（笔）</th>
						<th width="20%">营业额</th>
					</tr>
					<c:forEach var="item" items="${list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<tr class="${trClass}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td style="padding:4px 10px 4px 10px;">
							<div align="left"><c:forEach begin="1" end="${item[3]-1}" step="1">------</c:forEach><c:if test="${item[0]==null}">无项目类型</c:if><c:if test="${item[0]!=null}">${item[0].typeName}</c:if></div>
							<input type="radio" name='query_checkbox' value="" style="display:none">
						</td>
						<td style="padding:4px 10px 4px 10px;"><div align="right">${item[1]}</div></td>
						<td style="padding:4px 10px 4px 10px;"><div align="right"><c:if test="${item[0]!=null}"><a href="javascript:showDetail(${item[0].id});"></c:if>${item[2]}<c:if test="${item[0]!=null}"></a></c:if></div></td>
					</tr>
					</c:forEach>
				</table>
			</div>
		
 		</div>
  </div>
<div>
</body>
</html>